﻿Namespace Model
    Public Class NailService
#Region "Properties"
        Private _code As Integer
        Public Property UniqueCode() As Integer
            Get
                Return _code
            End Get
            Set(ByVal value As Integer)
                _code = value
            End Set
        End Property

        Private _name As String
        Public Property Name() As String
            Get
                Return _name
            End Get
            Set(ByVal value As String)
                _name = value
            End Set
        End Property

        Private _price As Double
        Public Property Price() As Double
            Get
                Return _price
            End Get
            Set(ByVal value As Double)
                _price = value
            End Set
        End Property

        Private _valid As Boolean
        Public Property IsValid() As Boolean
            Get
                Return _valid
            End Get
            Set(ByVal value As Boolean)
                _valid = value
            End Set
        End Property
#End Region

#Region "Creation"
        Protected Sub New()
        End Sub

        Public Shared Function CreateNewNailService()
            Return New NailService()
        End Function

        Public Shared Function CreateNailService(ByVal code As Integer, _
                                                 ByVal name As String, _
                                                 ByVal price As Double, _
                                                 ByVal valid As Boolean)
            Dim n = New NailService()
            With n
                .UniqueCode = code
                .Name = name
                .Price = price
                .IsValid = valid
            End With

            Return n
        End Function
#End Region

#Region "Overriden Object"
        Public Overrides Function GetHashCode() As Integer
            Dim hashCode As Integer
            hashCode += UniqueCode.GetHashCode()
            hashCode += Name.GetHashCode()
            hashCode += Price.GetHashCode()
            hashCode += IsValid.GetHashCode()

            Return hashCode
        End Function

        Public Overrides Function Equals(ByVal obj As Object) As Boolean
            Dim other As NailService = TryCast(obj, NailService)
            If other Is Nothing Then
                Return False
            End If

            Return UniqueCode = other.UniqueCode
        End Function
#End Region
    End Class
End Namespace
